import time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
driver=webdriver.Chrome()
# driver=webdriver.Firefox()
#driver.get('http://101.133.169.100/yuns/index.php')
driver.get('https://www.huodongxing.com')
# time.sleep(3)
driver.maximize_window()#设置窗体最大化
# ele=driver.find_element_by_link_text('家电数码')
# time.sleep(2)
# ActionChains(driver).move_to_element(ele).perform()#把鼠标移到ele元素上，通过perform真正去执行
# time.sleep(2)
# driver.find_element_by_link_text('手机').click()
#
# ActionChains(driver).context_click(ele).perform()#右击选中的标签元素
# ActionChains(driver).double_click(ele).perform()#双击选中的标签元素
time.sleep(2)

driver.find_element_by_link_text('注册').click()
time.sleep(2)
driver.find_element_by_xpath('//span[text()="点击按钮进行验证"]').click()
time.sleep(3)
source=driver.find_element_by_xpath('//div[@class="geetest_slider_button"]')#定位起始的标签
# target=driver.find_element_by_xpath("xxx")#无法定位滑动后的标签
# ActionChains(driver).drag_and_drop(source, target)#滑动滑块，假设可以执行

siz=driver.find_element_by_xpath('//div[@class="geetest_slider_track"]/..').size#定位滑动块所在的div的宽度
div_width=siz['width']
ActionChains(driver).drag_and_drop_by_offset(source,div_width*(1/3),0).perform()#向右滑动三分之一

time.sleep(2)
driver.quit()